﻿using _2DGame_Preview_Server.Services.RoomAndBattle.Room.Modle;
using TMPro;
using UnityEngine;

namespace Script.UiSystem.Room
{
    public class PlayerModel : MonoBehaviour
    {
        [SerializeField] private TextMeshProUGUI name;
        [SerializeField] private TextMeshProUGUI ready;

        public static readonly string Ready = "Ready";
        public static readonly string NotReady = "NotReady";
        
        private PlayerInfo_Room player;

        public int PlayerId => player.roleData.id;
        
        public void Init(PlayerInfo_Room player)
        {
            this.player = player;
            name.text = player.roleData.name;
            ready.text = this.player.isReady ? Ready : NotReady;
        }

        public void UpdateStatus(bool status)
        {
            player.isReady = status;
            ready.text = status ? Ready : NotReady;
        }

    }
}